import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';

@Component({
  template: `
    <p>Dock</p>
    <p>Session ID:{{ sessionId | async }}</p>
    <a id="anchor"></a>
    <p>Token:{{ token | async }}</p>
  `
})
export class AdminDockComponent implements OnInit {
  public sessionId: Observable<string>;
  public token: Observable<string>;

  constructor(private route: ActivatedRoute) { }

  public ngOnInit() {
    this.sessionId = this.route
      .queryParams
      .map((params) => params['session_id'] || 'None');

    this.token = this.route
      .fragment
      .map((fragment) => fragment || 'None');
  }
}
